package actions;

import java.util.concurrent.locks.ReentrantLock;
/**
 * this is thread-safe defaultbaseaction.
 * @author cjcj
 *
 */
public abstract class DefaultBaseAction implements Action{

	private ReentrantLock lock=new ReentrantLock();
    protected ActionFactory factory;
    //protected String cmd="default";
	public DefaultBaseAction(ActionFactory factory){
		this.factory=factory;
	}
	public Object call(){
		lock.lock();
		try{
		Object rs=call0();
		return rs;
		}catch(Exception e){
		return null;
		}finally{
		lock.unlock();
		}
	}

	protected abstract Object call0();
	/*public boolean checkCmd(String cmd){
		return this.cmd.equals(cmd);
	}*/
}
